<?php
  
  require "../framework.php"; 
  //json::getSqlJson("SHOW FIELDS FROM page");
  //json::exportJSON("page");

  $json = '{ "items": [       ';
/*  $json    =$json . "{";
  $json    =$json . "\"items\": [       ";
  $json = $json . "{";*/ 
  
  $sql = "SHOW FIELDS FROM ".$_REQUEST['table'];
  
  $data = new data();
  $data->getQuery($sql);
         
         
         //echo "([";
 /* {name:"a name", comment:"a comment"},
  {name:"a name", comment:"a comment"},
  { etc }
])*/
         
         
         do {
           
              $jsonData = array();
              $jsonData['field'] = $data->data['field'];
              $json = $json.json_encode($jsonData);
              $json = $json.",";   
             //echo serialize($data->data);
             //echo json_encode($data->data).",";
             
         } while($data->nextRow());
  
  
  
  
 /* $users = array();
  $users['name'] = "Suppen";
  $json = $json.json_encode($users);
//  $json=$json . "}]}";         
    $json = $json.",";

  $users = array();
  $users['name'] = "Suppen 7777";
  $json = $json.json_encode($users);
  $json = $json.",";     */

    
    
    
        $json=substr($json, 0, strlen($json) - 1)." ]}";   
        echo $json;
  

 /* $users = array();
  $users['name'] = "Erik";
  echo json_encode($users);   */



  //$users[] = array('name' => 'Dave', 'email' => 'dave@adeepersilence.be');
  //$users = array('name' => 'Kurs Klang', 'email' => 'dave@adeepersilence.be');

  //$users[4] = array('name' => 'Erik', 'email' => 'erik@bauffman.be');


    // echo (not return) the wanted record from the users array
    

  
  
?>